﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using helloworld2;
using helloworld2.MODEL;

namespace helloworld2
{
    class City
    {
        public int id { get; set; }
        public string name { get; set; }
        KeyValuePair<int, int> coordinates;
        List<KeyValuePair<int, int>> field = new List<KeyValuePair<int,int>>();
        CityContainer cc = CityContainer.Instance;
        EdgeContainer ec = EdgeContainer.Instance;
        private List<Road> connections = new List<Road>();

        public City(int id, string name, int y, int x, List<KeyValuePair<int, int>> field)
        {
            this.id = id;
            this.field = field;
            this.name = name;
            this.coordinates = new KeyValuePair<int, int>(y, x);
            Edge e = new Edge(this.id, 7*1.2, true);
        }

        public City()
        {
        }

        public KeyValuePair<int, int> getCoordinates()
        {
            return coordinates;
        }

        public List<KeyValuePair<int, int>> getField()
        {
            var newField = new List<KeyValuePair<int, int>>();
            foreach (KeyValuePair<int, int> kp in field)
            {
                newField.Add(kp);
            }
            return newField;
        }

        public bool lookForCoordinates(KeyValuePair<int, int> coordinates)
        {
            bool re = false;
            if (field.Contains(coordinates))
            {
                re = true;
            }
            return re;
        }

        public List<Road> getConnection()
        {
            List<Road> recon = new List<Road>();
            foreach (Road r in connections)
            {
                recon.Add(r);
            }
            return recon;
        }

        public void addConnection(Road r)
        {
            Console.WriteLine("Added one road to city");
            connections.Add(r);
        }
    }
}
